
import {defineStore} from "pinia";
import {reactive} from "vue";
import axios from "axios";

export const useGoodsSotre = defineStore("goods", ()=>{
    const goodsList = reactive([]);
    
    // 获取商品列表：
    const getGoodsList = (count:number=1,limitNum:number=10,isAdd:boolean=false)=>{
        axios({
            url:"http://121.89.205.189:3000/api/pro/seckilllist",
            params:{
                count,
                limitNum
            }
        }).then(res=>{
            if(res.data.code==="200"){
                !isAdd && (goodsList.length = 0);
                goodsList.push(...res.data.data);
            }
        })
    }

    return {
        goodsList,getGoodsList
    }
})